﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace ButtonTree2
{
    static class RibbonFlatStylePaintUtils
    {
        public static void PaintButton(Graphics g, Rectangle rect, Color colorFill, Color colorBorder, Color colorLightBorder)
        {
            Rectangle rectDraw = new Rectangle(rect.Left, rect.Top, rect.Width - 1, rect.Height - 1);
            using (Pen pen = new Pen(colorBorder))
            {
                using (Brush brush = new SolidBrush(colorFill))
                {
                    RibbonGraphicsUtils.DrawRoundRect(g, pen, brush, rectDraw, 3f);
                }
            }


            // 边框加亮
            using (Pen pen = new Pen(colorLightBorder, 1))
            {
                RibbonGraphicsUtils.DrawRoundRect(g, pen, null,
                    new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 3, rect.Height - 3), 3f);
            }
        }

        public static void PaintMiddleLine(Graphics g, Rectangle rect, bool isLarge, int offsetMiddle, Color colorLine, Color colorLight)
        {
            using (Pen penLight = new Pen(colorLight))
            {
                using (Pen penLine = new Pen(colorLine))
                {
                    if (isLarge)
                    {
                        // draw large button middle line
                        g.DrawLine(penLight, new Point(rect.Left + 1, rect.Top + offsetMiddle + 1), new Point(rect.Right - 2, rect.Top + offsetMiddle + 1));
                        g.DrawLine(penLine, new Point(rect.Left + 1, rect.Top + offsetMiddle), new Point(rect.Right - 2, rect.Top + offsetMiddle));
                    }
                    else
                    {
                        // draw small button middle line
                        g.DrawLine(penLine, new Point(rect.Right - offsetMiddle, rect.Top + 1),
                            new Point(rect.Right - offsetMiddle, rect.Bottom - 2));
                    }
                }
            }
        }
    }
}
